package org.vectrics.recruiter.struts.tag;

/**
 * Title:        vectrics Server for Logging
 * Description:
 * Copyright:    Copyright (c) 2001
 * Company:      vectrics Software Inc.  Service is Built In
 * @author Mike Moore
 * @version 1.0
 */
import java.util.*;
import org.apache.log4j.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.TagSupport;

public class TextImageTag extends TagSupport {

	private static final long serialVersionUID = -2040233633816063268L;
	
	static private Category log = Category.getInstance(TextImageTag.class);
	private String text = null;
	private String size = "18";
    
    public TextImageTag() {
    	super();
    }
    
	public int doStartTag() throws JspException  {
		StringBuffer html = new StringBuffer();
		
		log.debug("doStartTag() called");
		HttpServletRequest request = (HttpServletRequest)super.pageContext.getRequest();
		String contextPath = request.getContextPath();
		Date now = new Date();
		String imageName = "" + now.getTime();
		String path = "/graphics-gen/" + imageName + ".jpg?type=text&size=" + size + "&height=20&width=300&text=" + getText();
		html.append("<img src=\"" + path + "\">");

		
		JspWriter writer = pageContext.getOut();
		try {
			log.info("html = " + html.toString());
			writer.print(html.toString());
		}
		catch (java.io.IOException ex) {
			throw new JspException("IOException attempting to write tag to output. " + ex.getMessage());
		}
		return(EVAL_PAGE);
	}
    
    
	/**
	 * @return
	 */
	public String getText() {
		return text;
	}

	/**
	 * @param text
	 */
	public void setText(String text) {
		this.text = text;
	}

	/**
	 * @return
	 */
	public String getSize() {
		return size;
	}

	/**
	 * @param size
	 */
	public void setSize(String size) {
		this.size = size;
	}

}
